# 封装
class BackAccount:
    def __init__(self, number, holder, balance, phone):
        # 设置为私有属性，只能在类的内部访问
        # 以 __ 开头的属性就是私有属性
        self.__account_number = number
        self.account_holder = holder
        self.__balance = balance
        self.__phone = phone
    # 添加方法，用来访问私有属性
    def get_account_number(self):
        return self.__account_number
    def get_balance(self):
        return self.__balance
    def get_phone(self):
        return self.__phone
    def set_phone(self,phone):
        self.__phone = phone    
    # 设置私有方法    
    def __add_amount(self, amount):
        self.__balance += amount
    def __del_amount(self,amount):
        self.__balance -= amount    
    # 使用私有方法的接口    
    def cunkuan(self,num):
        if num > 0:
            self.__add_amount(num)
            print('yes:', self.__balance)
        else:
            print('NO: num Error')   
    def qukuan(self, num):
        if self.__balance >= num and num > 0:
            self.__del_amount(num)
            print('yes:', self.__balance)
        elif self.__balance < num:
            print('not balance')            
        else:
            print('NO: num Error')

if __name__ == '__main__':
    a1 = BackAccount('532222', 'tom', 1000)
    # 通过方法访问私有属性
    print(a1.get_account_number(), a1.account_holder, a1.get_balance(), a1.get_phone())
    a2 = BackAccount('544444', 'jenkins', 500)
    a2.cunkuan(1000)
